import { JupiterConfig, JupiterConfigQuery } from '../types/configTypes';
import request from 'utils/request';

export const fetchConfigList = (params: JupiterConfigQuery) => {
  return request.post('/configs/page', params);
};

export const fetchConfigById = (uuid: string) => {
  return request.get(`/configs/${uuid}`);
};

export const createConfig = (data: Partial<JupiterConfig>) => {
  return request.post('/configs', data);
};

export const updateConfig = (uuid: string, data: Partial<JupiterConfig>) => {
  return request.put(`/configs/${uuid}`, data);
};

export const deleteConfig = (uuid: string) => {
  return request.delete(`/configs/${uuid}`);
};

export const updateConfigStatus = (uuid: string, status: number) => {
  return request.put(`/configs/${uuid}/status`, { status });
};

export const fetchConfigByKey = (configKey: string) => {
  return request.get(`/configs/key/${configKey}`);
};

export const refreshConfigCache = () => {
  return request.post('/configs/refresh-cache');
};
